// 导入所需的模块
import { buildBundle } from './build-bundle.js';
import { calculateArb } from './calculate-arb.js';
import { mempool } from './mempool.js';
import { postSimulateFilter } from './post-simulation-filter.js';
import { preSimulationFilter } from './pre-simulation-filter.js';
import { sendBundle } from './send-bundle.js';
import { simulate } from './simulation.js';

// 这些都是异步生成器，本质上是带类型的数据流
// 从内存池获取交易更新
const mempoolUpdates = mempool();
// 对交易进行预模拟过滤
const filteredTransactions = preSimulationFilter(mempoolUpdates);
// 模拟交易执行
const simulations = simulate(filteredTransactions);
// 对模拟结果进行后处理过滤，找出可以背后交易的机会
const backrunnableTrades = postSimulateFilter(simulations);
// 计算套利机会
const arbIdeas = calculateArb(backrunnableTrades);
// 构建交易包
const bundles = buildBundle(arbIdeas);
// 发送交易包
await sendBundle(bundles);
